import React from 'react';
import user from "./dataContext/user";

class SecondComponent extends React.Component {
    changeUserName = function () {
        user.set('222')
    };
    render() {
        return (
            <div>
                <h3>SecondComponent <button onClick={this.changeUserName}>change222</button></h3>
                <h5>username: {user.get()}</h5>
            </div>
        );
    }
    componentDidMount() {
        this.setState()
        user.addListener(() => {
            this.forceUpdate()
        })
    }
}
export default SecondComponent